package com.example.mcpweather.tool;

import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
@Slf4j
public class McpWeatherTool {
    /**
     * 城市天气获取工具
     */

    HashMap<String,Integer> code = new HashMap<>(){{
        put("成都",510100);
    }};
    //String key = "ayK97BaQsrqmHqmLoaDy1VD31X6MUZDT";
    @Tool(name="getWeatcher",description = "获取城市天气信息")
    public String getWeatcher(@ToolParam(description = "城市",required = true)String city){
        String url = "https://api.map.baidu.com/weather/v1/?district_id="+code.get(city)+"&data_type=all&ak=ayK97BaQsrqmHqmLoaDy1VD31X6MUZDT";
        log.info("查询天气城市 = {}",code.get( city));
        log.info("查询天气url = {}",url);
        return HttpUtil.get(url);
    }




}
